Ext.define('App.datacollection.taskinstance.model.TaskInstanceViewModel', {
    extend: 'Ext.app.ViewModel',
    alias: 'viewmodel.TaskInstanceViewModel',
    requires: ['App.datacollection.taskinstance.model.TaskInstanceModel'],
    data: {
        columns: [{
            text: 'ID',
            dataIndex: 'id',
            hidden: true,
            sortable: false
        }, {
            text: '任务分组',
            dataIndex: 'group',
            sortable: true,
            flex: 1
        }, {
            text: '任务名称',
            dataIndex: 'name',
            sortable: true,
            flex: 3
        }, {
            xtype: 'ymdhiscolumn',
            text: '开始时间',
            dataIndex: 'startTime',
            sortable: true,
            flex: 3
        }, {
            text: '结束时间',
            dataIndex: 'endTime',
            sortable: true,
            flex: 3
        }, {
            text: '执行方式',
            dataIndex: 'collectionSchedule',
            sortable: true,
            flex: 3,
            renderer: function (v, m, r) {
                console.log(v)
                if (v) {
                    return "计划执行"
                } else {
                    return "手动执行"
                }
            }
        }, {
            text: '状态',
            dataIndex: 'status',
            sortable: true,
            flex: 3,
            renderer: function (v, m, r) {
                var show = 5;
                var status = {1: "等执行", 2: "执行中", 3: "已完成", 4: "失败", 5: "异常", 6: "系统终止", 7: "用户终止"};
                return status[v];
                return show;
            }
        }],
        search: {
            fields: [{
                name: "任务分组",
                field: 'group',
                vtype: 's',
                defaultValue: '',
                opt: 'like',
                datas: null
            }, {
                name: "任务名称",
                field: 'name',
                vtype: 's',
                defaultValue: '',
                opt: 'like',
                datas: null
            }]
        }
    },
    stores: {
        Query: {
            autoLoad: false,
            model: 'App.datacollection.taskinstance.model.TaskInstanceModel',
            pageSize: 25,
            remoteSort: true,
            sorters: [{
                property: 'startTime',
                direction: 'DESC'
            }],
            proxy: {
                type: 'majax',
                url: 'datacollection/task_instance/query',
                reader: {
                    type: 'json',
                    rootProperty: 'data',
                    totalProperty: 'total'
                }
            }
        }
    }
});